<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:poue="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>
                    <p:panel id="panelReport" >
                        <f:facet name ="header" >
                            <h:outputLabel styleClass="noPrintButton"  value="Lab Handover Report" />
                            <p:calendar styleClass="noPrintButton" value="#{institutionLabSumeryController.fromDate}" pattern="dd MMMM yyyy hh:mm a" >
                            </p:calendar>
                            <p:calendar styleClass="noPrintButton" value="#{institutionLabSumeryController.toDate}" pattern="dd MMMM yyyy hh:mm a" >
                            </p:calendar>
                            <h:outputLabel styleClass="noPrintButton" value="Institution" style="text-align: left; margin: 5px; padding: 5px;" ></h:outputLabel>
                            <p:autoComplete styleClass="noPrintButton"  value="#{institutionLabSumeryController.institution}" 
                                            style="text-align: left; margin: 5px; padding: 5px;" 
                                            completeMethod="#{institutionController.completeIns}" 
                                            var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                            </p:autoComplete>
                            <p:commandButton styleClass="noPrintButton" value="Refresh" ajax="false" ></p:commandButton>
                            <p:commandButton styleClass="noPrintButton" value="Print" ajax="false" >
                                <p:printer target="panelReport" />
                            </p:commandButton>

                            <p:commandButton ajax="false" value="Excel"  styleClass="noPrintButton" style="float: right;" >
                                <poue:exporter type="xlsx" target="tbl" fileName="PlayersStatistics" subTable="true"  />  
                            </p:commandButton>

                        </f:facet>


                        <p:panel styleClass="printBlock" >
                            <h:outputLabel value="#{labels.topic}" styleClass="rh1" /> 
                            <br/>
                            <h:outputLabel value="#{institutionLabSumeryController.institution.name}"  >
                            </h:outputLabel>
                            <h:outputLabel value=" - Handover Report" />
                            <br/>
                            <h:outputLabel value="From : " />
                            <h:outputLabel value="#{institutionLabSumeryController.fromDate}"  >
                                <f:convertDateTime pattern="dd MMMM yyyy hh:mm a" />
                            </h:outputLabel>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <h:outputLabel value="To : "  ></h:outputLabel>
                            <h:outputLabel value="#{institutionLabSumeryController.toDate}" >
                                <f:convertDateTime pattern="dd MMMM yyyy hh:mm a" />
                            </h:outputLabel>

                        </p:panel>

                        <p:dataTable id="tbl" value="#{institutionLabSumeryController.labBillsIns}" var="b" sortBy="#{b.billClass}" >

                            <f:facet name="header">
                                <h:outputLabel value="jhgjhg"/>
                            </f:facet>

                            <p:column headerText="BillId" >

                                <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                    <h:outputLabel value="#{b.insId}" ></h:outputLabel>
                                </h:panelGroup>

                                <h:panelGroup rendered="#{b.billClass ne 'class com.divudi.entity.BilledBill'}" >
                                    <h:outputLabel value="#{b.billedBill.insId}" ></h:outputLabel>
                                </h:panelGroup>

                            </p:column>

                            <p:column headerText="Billed Institution">
                                <h:outputLabel value="#{b.institution.name}"/>
                            </p:column>

                            <p:column headerText="To Institution">
                                <h:outputLabel value="#{b.toInstitution.name}"/>
                            </p:column>

                            <p:column headerText="To Department">
                                <h:outputLabel value="#{b.toDepartment.name}"/>
                            </p:column>

                            <p:column headerText="Name" >
                                <h:outputLabel value="#{b.patient.person.name}"/>
                            </p:column>

                            <p:column headerText="Hospital Fee" style="text-align: right;">
                                <h:outputLabel value="#{b.total - b.staffFee}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:column headerText="Dis." style="text-align: right;">
                                <h:outputLabel value="#{b.discount}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:column headerText="Prof. Fee" style="text-align: right;">
                                <h:outputLabel value="#{b.staffFee}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:column headerText="Net Total" style="text-align: right;">
                                <h:outputLabel value="#{b.netTotal}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </p:column>

                            <p:summaryRow>
                                <p:column colspan="5" >
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <h:outputLabel value="Billed Bill Totals"/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <h:outputLabel value="Cancelled Bill Totals"/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <h:outputLabel value="Refund Bill Totals"/>
                                    </h:panelGroup>
                                </p:column>
                                <p:column  >
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.hosTotB}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.hosTotC}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.hosTotR}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                </p:column>
                                <p:column  >
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.disTotB}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.disTotC}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.disTotR}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                </p:column>
                                <p:column  >
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.profTotB}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.profTotC}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.profTotR}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                </p:column>
                                <p:column  >
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.BilledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.netTotB}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.CancelledBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.netTotC}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{b.billClass eq 'class com.divudi.entity.RefundBill'}" >
                                        <h:outputLabel value="#{institutionLabSumeryController.netTotR}" >
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </h:panelGroup>
                                </p:column>
                            </p:summaryRow>
                            <f:facet name="footer" >
                                <p:panelGrid columns="2" style="text-align: right;" >
                                    <h:outputLabel value="Total Hospital Fee" ></h:outputLabel>
                                    <h:outputLabel value="#{institutionLabSumeryController.hosTot }" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                    <h:outputLabel value="Total Discount" ></h:outputLabel>
                                    <h:outputLabel value="#{institutionLabSumeryController.disTot}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                    <h:outputLabel value="Total Net" ></h:outputLabel>
                                    <h:outputLabel value="#{institutionLabSumeryController.netTot}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                    <h:outputLabel value="Total Professional Fee" ></h:outputLabel>
                                    <h:outputLabel value="#{institutionLabSumeryController.profTot}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                    <h:outputLabel value="" ></h:outputLabel>
                                    <h:outputLabel value="" ></h:outputLabel>
                                    <h:outputLabel  value="Net Department Income" ></h:outputLabel>
                                    <h:outputLabel  value="#{institutionLabSumeryController.labHandover}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </p:panelGrid>
                            </f:facet>
                        </p:dataTable>

                    </p:panel>

                </h:form>
            </ui:define>



        </ui:composition>

    </h:body>
</html>
